//
//  BuyCarDetailVC.m
//  New_Runway
//
//  Created by mack on 2018/2/12.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "BuyCarDetailVC.h"
#import <SDCycleScrollView.h>
#import "UITableView+FDTemplateLayoutCell.h"
#import "BuyCarDetailTopCell.h"
#import "CarFloorPriceCell.h"
#import "CardescribeCell.h"

#import "CarConfigHeaferView.h"
#import "CarConfigInfoModel.h"
#import "CarConfigCell.h"
#import "CarBaseInfoCell.h"
#import "CarRadarDataCell.h"


@interface BuyCarDetailVC ()<UITableViewDelegate,UITableViewDataSource,SDCycleScrollViewDelegate>
@property(nonatomic, strong) UITableView *tableview;
@property (nonatomic,strong) SDCycleScrollView *bannerView;
@property (nonatomic, strong) UILabel *bannerL;
@property (nonatomic, strong) NSMutableArray *imageUrls;
@property (nonatomic, strong) CarBaseInfoModel *infomodel;
//@property (nonatomic, strong) UIButton *bottomBtn;
@property (nonatomic, strong) NSMutableArray *listArray;
@property (nonatomic, strong) NSMutableArray *infoData;
@property (nonatomic, strong) NSMutableArray *imageDealUrlS;
@property (nonatomic, strong) UIButton *collectionBtn;
@property (nonatomic, assign) NSInteger collectionState;
@property (nonatomic, copy) NSString *carFavoriteId;
@end

@implementation BuyCarDetailVC
-(NSMutableArray *)listArray{
    if (!_listArray) {
        _listArray = [[NSMutableArray alloc] init];
    }
    return _listArray;
}
-(NSMutableArray *)imageDealUrlS{
    if (!_imageDealUrlS) {
        _imageDealUrlS = [[NSMutableArray alloc] init];
    }
    return _imageDealUrlS;
    
}
-(NSMutableArray *)infoData{
    
    if (!_infoData) {
        _infoData = [[NSMutableArray alloc] init];
    }
    return _infoData;
}
-(NSMutableArray *)imageUrls{
    if (!_imageUrls) {
        
        _imageUrls = [[NSMutableArray alloc] init];
    }
    return _imageUrls;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationBarView.titleLabel.text = @"车辆详情";
    self.view.backgroundColor = kColorWhite();
    [self.navigationBarView.rightItem setTitle:@"联系商家" forState:UIControlStateNormal];
    [self initTableview];
    [self creatBannerView];
    [self loadCarBaseInfo];
    [self loadCarCollectionInfo];

    if ([NRWCarUser sharedUser].shopId) {
        if (self.isHistory == YES) {
            
        }else{
            [[FMDBInfo sharedDataBase] addCarList:self.carModel];
            NSMutableArray *arraya = [[FMDBInfo sharedDataBase] getAllCarLsit];
            if (arraya.count > 50) {
                Result *res = arraya[0];
                [[FMDBInfo sharedDataBase]deleteCarList:res];
            }
        }
    }
    
    
}
-(void)loadCarCollectionInfo{
    
    NSString *url = [NSString stringWithFormat:@"%@%@",Api,isCollectionApi];
    [YQNetworking postWithUrl:url refreshRequest:YES cache:NO params:@{@"userId":[NRWCarUser sharedUser].userId, @"carId":self.carID} progressBlock:^(int64_t bytesRead, int64_t totalBytes) {
        
    } successBlock:^(id response) {
        if ([response[@"code"] isEqual:@1]) {
            if ([NRWCarUser sharedUser].shopId) {
                NSString *state = response[@"result"][@"favoriteState"];
                self.collectionState = [state integerValue];
                self.carFavoriteId = response[@"result"][@"carFavoriteId"];
                [self.bannerView addSubview:self.collectionBtn];
            }
        }
    } failBlock:^(NSError *error) {
        [ShowMessage showHintMessage:@"请求失败!" duration:2.0 withRemindId:remindFail];

    }];
    
   
}
-(void)carInfo{
    
    NSArray *arr = @[@{@"childCarConf":@[
                               
                               @{
                                   @"confName":@"厂商",
                                   @"infoName": _infomodel.result.model.modelManufacturer ?_infomodel.result.model.modelManufacturer : @"--"
                                   },
                               @{
                                   @"confName":@"发动机",
                                   @"infoName":_infomodel.result.model.modelEngineModel ?_infomodel.result.model.modelEngineModel : @"--"
                                   
                                   },
                               @{
                                   @"confName":@"变速箱",
                                   @"infoName":_infomodel.result.model.modelGearbox ?_infomodel.result.model.modelGearbox : @"--"
                                   
                                   },
                               @{
                                   @"confName":@"车身结构",
                                   @"infoName":_infomodel.result.model.modelBodywork ?_infomodel.result.model.modelBodywork : @"--"
                                   
                                   }
                               
                               ],
                       @"confName":@"基本参数",
                       @"selectedState":@"0"
                       },
                     
                     @{@"childCarConf":@[
                               
                               @{
                                   @"confName":@"长度（mm）",
                                   @"infoName":_infomodel.result.model.modelLength ? _infomodel.result.model.modelLength : @"--"
                                   },
                               @{
                                   @"confName":@"宽度（mm）",
                                   @"infoName":_infomodel.result.model. modelWidth ? _infomodel.result.model. modelWidth : @"--"
                                   
                                   },
                               @{
                                   @"confName":@"高度（mm）",
                                   @"infoName":_infomodel.result.model.modelHeight ? _infomodel.result.model.modelHeight : @"--"
                                   
                                   },
                               @{
                                   @"confName":@"轴距（mm）",
                                   @"infoName":_infomodel.result.model.modelWheelbase ? _infomodel.result.model.modelWheelbase : @"--"
                                   
                                   },
                               @{
                                   @"confName":@"车身结构",
                                   @"infoName":_infomodel.result.model.modelBody ? _infomodel.result.model.modelBody : @"--"
                                   
                                   }
                               
                               
                               ],
                       @"confName":@"车身",
                       @"selectedState":@"0"
                       },
                     @{@"childCarConf":@[
                               
                               @{
                                   @"confName":@"发动机型号",
                                   @"infoName":_infomodel.result.model.modelEngineModel ? _infomodel.result.model.modelEngineModel : @"--"
                                   },
                               @{
                                   @"confName":@"排量（ml）",
                                   @"infoName":_infomodel.result.model.modelDisplacement ? _infomodel.result.model.modelDisplacement : @"--"
                                   
                                   },
                               @{
                                   @"confName":@"进气形式",
                                   @"infoName":_infomodel.result.model.modelInletModel ? _infomodel.result.model.modelInletModel : @"--"
                                   
                                   },
                               @{
                                   @"confName":@"气缸排列形式",
                                   @"infoName":_infomodel.result.model.modelCylinderArray ? _infomodel.result.model.modelCylinderArray : @"--"
                                   
                                   },
                               @{
                                   @"confName":@"气缸数（个）",
                                   @"infoName":_infomodel.result.model.modelCylinderNum ? _infomodel.result.model.modelCylinderNum : @"--"
                                   
                                   },
                               @{
                                   @"confName":@"燃料形式",
                                   @"infoName":_infomodel.result.model.modelFuelRoz ? _infomodel.result.model.modelFuelRoz :@"--"
                                   
                                   },
                               @{
                                   @"confName":@"环保标准",
                                   @"infoName":_infomodel.result.model.modelEnviron ? _infomodel.result.model.modelEnviron : @"--"
                                   
                                   }
                               
                               ],
                       @"confName":@"发动机",
                       @"selectedState":@"0"
                       },
                     @{@"childCarConf":@[
                               
                               @{
                                   @"confName":@"变速箱类型",
                                   @"infoName":_infomodel.result.model.modelGearbox ? _infomodel.result.model.modelGearbox : @"--"
                                   },
                               @{
                                   @"confName":@"档位个数",
                                   @"infoName":_infomodel.result.model.modelGearNum ? _infomodel.result.model.modelGearNum : @"--"
                                   
                                   }
                               
                               
                               ],
                       @"confName":@"变速箱",
                       @"selectedState":@"0"
                       },
                     
                     ];
    for (NSDictionary *dic in arr) {
        CarConfigResult *child = [CarConfigResult mj_objectWithKeyValues:dic];
        [self.listArray addObject:child];
        
    }
    [self loadCarConfigInfo];
}

-(void)rightItemClick{

    [self CallShop];
}
-(void)CallShop{
    
    NSMutableString *str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_infomodel.result.user.userMobile];
    UIWebView *callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
    [self.view addSubview:callWebview];

}
-(void)initTableview{
    kSelfWeak;
    self.tableview = [[UITableView alloc] init];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    self.tableview.backgroundColor = MAIN_COLOR();
    _tableview.estimatedRowHeight = 0;
    _tableview.estimatedSectionHeaderHeight = 0;
    _tableview.estimatedSectionFooterHeight = 0;
    self.tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableview registerNib:[UINib nibWithNibName:@"BuyCarDetailTopCell" bundle:nil] forCellReuseIdentifier:@"BuyCarDetailTopCell"];
    [self.tableview registerNib:[UINib nibWithNibName:@"CarFloorPriceCell" bundle:nil] forCellReuseIdentifier:@"CarFloorPriceCell"];
    [self.tableview registerNib:[UINib nibWithNibName:@"CardescribeCell" bundle:nil] forCellReuseIdentifier:@"CardescribeCell"];
    [self.tableview registerClass:[CarConfigHeaferView class] forHeaderFooterViewReuseIdentifier:@"header"];
    [self.tableview registerClass:[CarConfigCell class] forCellReuseIdentifier:@"CarConfigCell"];
    [self.tableview registerClass:[CarBaseInfoCell class] forCellReuseIdentifier:@"CarBaseInfoCell"];
    [self.tableview registerClass:[CarRadarDataCell class] forCellReuseIdentifier:@"CarRadarDataCell"];
    if (@available(iOS 11.0, *)) {
        self.tableview.contentInsetAdjustmentBehavior = UIApplicationBackgroundFetchIntervalNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = false;
    }
    
    [self.view addSubview:self.tableview];
    [self.tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.view);
        make.top.equalTo(weakSelf.view).mas_offset(self.navH);
        make.bottom.equalTo(weakSelf.view).mas_offset(-self.BotH);
    }];

}
-(void)creatBannerView{
    
//    if (_imageUrls.count == 0) {
//        return;
//    }
    self.bannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.width * 3 / 4) delegate:self placeholderImage:[UIImage imageNamed:@"banner"]];
    self.bannerView.currentPageDotImage = [UIImage imageWithColor:[UIColor clearColor] forSize:CGSizeMake(15, 2)];
    self.bannerView.pageDotImage = [UIImage imageWithColor:[UIColor clearColor] forSize:CGSizeMake(15, 2)];
    self.bannerView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
    self.tableview.tableHeaderView = self.bannerView;
    //    self.bannerView.autoScroll = NO;
    [self.view bringSubviewToFront:self.navigationBarView];
    self.bannerL = [[UILabel alloc] initWithFrame:CGRectMake(Screen_width - 65, Screen_width  * 3/4 - 40, 50, 25)];
    self.bannerL.layer.masksToBounds = YES;
    self.bannerL.layer.cornerRadius = 25/2;
    self.bannerL .backgroundColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.7];
    self.bannerL.textColor = kColorWhite();
    self.bannerL.textAlignment = NSTextAlignmentCenter;
    [self.bannerView addSubview:self.bannerL];
   
}
-(UIButton *)collectionBtn{
    if (!_collectionBtn) {
        _collectionBtn = [[UIButton alloc] init];
        _collectionBtn.frame = CGRectMake(Screen_width - 63, 15, 37, 37);
        if (self.collectionState == 1) {
            _collectionBtn.selected = YES;
            [_collectionBtn setImage:[UIImage imageNamed:@"collection"] forState:UIControlStateNormal];
        }else{
            _collectionBtn.selected = NO;
            [_collectionBtn setImage:[UIImage imageNamed:@"cancel_collection"] forState:UIControlStateNormal];
        }
        [_collectionBtn addTarget:self action:@selector(collectionThisCar:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _collectionBtn;
}
-(void)collectionThisCar:(UIButton *)sender{
    
    if (sender.tag == 10) {//按钮已经点击过, 但是请求响应暂时没有返回, 拒绝接受点击事件, return
        return;
    }
    
    sender.selected = !sender.selected;
    NSString *url;
    NSDictionary *params;
    if (sender.selected == YES) {
        [sender setImage:[UIImage imageNamed:@"collection"] forState:UIControlStateNormal];
        url = [NSString stringWithFormat:@"%@%@",Api,collectionCarApi];
        params = @{
                   @"carId":self.carID,
                   @"userId":[NRWCarUser sharedUser].userId
                   };
        
    }else{
        [sender setImage:[UIImage imageNamed:@"cancel_collection"] forState:UIControlStateNormal];
        url = [NSString stringWithFormat:@"%@%@",Api,cancelCollectionCarApi];
        params = @{
                   @"carFavoriteId":self.carFavoriteId,
                   @"userId":[NRWCarUser sharedUser].userId
                   };
    }
    [self collectionCar:url withParams:params];

}
-(void)collectionCar:(NSString *)url withParams:(NSDictionary *)params{
    
    _collectionBtn.tag = 10;//设置为10 按钮已经点击过, 但是请求响应暂时没有返回, 拒绝接受点击事件
  
    [YQNetworking postWithUrl:url refreshRequest:NO cache:NO params:params progressBlock:nil successBlock:^(id response) {
        if ([response[@"code"] isEqual:@1]) {
            if (_collectionBtn.selected == YES) {
                if ([response isKindOfClass:[NSDictionary class]]) {
                    NSDictionary *result = response[@"result"];
                    if ([result isKindOfClass:[NSDictionary class]]) {
                        self.carFavoriteId = result[@"carFavoriteId"];
                    }
                }
                [ShowMessage showHintMessage:@"已添加至收藏车辆！" duration:2.0 withImageName:@"收藏"];
            }else{
                [ShowMessage showHintMessage:@"已取消收藏！" duration:2.0 withImageName:@"收藏"];

            }
        }else{
            [ShowMessage showHintMessage:response[@"msg"] duration:2.0 withRemindId:remindWarning];
        }
        
        _collectionBtn.tag = 1;//设置为1 按钮已经点击过, 请求响应也已经处理完成, 可以继续接受点击事件
        
    } failBlock:^(NSError *error) {
        _collectionBtn.tag = 1;//设置为1 按钮已经点击过, 请求响应也已经处理完成, 可以继续接受点击事件
        [ShowMessage showHintMessage:@"请求失败!" duration:2.0 withRemindId:remindFail];

    }];
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 3 + self.listArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            return [tableView fd_heightForCellWithIdentifier:@"BuyCarDetailTopCell" configuration:^(BuyCarDetailTopCell* cell) {
                cell.carInfo = _infomodel.result;
                
            }];
        }else{
            return 290;
        }
        
    }else if (indexPath.section == 1 ){
        return 250;
    }else if (indexPath.section == 2){
   
        return [tableView fd_heightForCellWithIdentifier:@"CardescribeCell" configuration:^(CardescribeCell* cell) {
            cell.index = indexPath.row;
            cell.carInfo = _infomodel.result;
   
        }];
    }
    return 41;
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
       
        return 2;
    }else if (section == 2){
        return 2;
    }else if (section == 1){
    return 1;
    }else{
        CarConfigResult *info = self.listArray[section - 3];
        if (info.selectedState == NO) {
            return 0;
        }else{
            return info.childCarConf.count;
        }
    }
   
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {
            BuyCarDetailTopCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BuyCarDetailTopCell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

            cell.carInfo = _infomodel.result;
            return cell;
        }else{
            
            CarRadarDataCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CarRadarDataCell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

            cell.carInfo = _infomodel.result;
            return cell;
        }
        
        
    }else if (indexPath.section == 1){
        
        CarFloorPriceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CarFloorPriceCell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        cell.carInfo = _infomodel.result;
        
        return cell;
    }else if (indexPath.section == 2){
        NSArray *titles = @[@"瑕疵描述",@"卖点描述",@"按揭说明",@"补充说明"];
        
        CardescribeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CardescribeCell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        cell.title = titles[indexPath.row];
        cell.index = indexPath.row;
        cell.carInfo = _infomodel.result;
        
        return cell;
 
    }else{
    
    CarConfigResult *info = self.listArray[indexPath.section - 3];
    Childcarconf *childInfo = info.childCarConf[indexPath.row];
    if (indexPath.section < 7) {
        CarBaseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CarBaseInfoCell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        cell.leftLable.text = childInfo.confName;
        cell.rightLable.text = childInfo.infoName;
        return cell;
    }
    
    CarConfigCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CarConfigCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.label.text = childInfo.confName;
    if (childInfo.selectedState == YES) {
        cell.leftImage.image = [UIImage imageNamed:@"hook"];
    }else{
        
        cell.leftImage.image = [UIImage imageNamed:@"circle"];
        
    }
    return cell;
}
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section < 3) {
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = UIColorHex(0xf5f5f5);
        UIView *lineview = [[UIView alloc] init];
        lineview.backgroundColor = MAIN_NAV_COLOR();
        [view addSubview:lineview];
        [lineview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.equalTo(view);
            make.width.mas_offset(2);
        }];
        UILabel *title = [[UILabel alloc] init];
        [view addSubview:title];
        [title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view).mas_offset(16);
            make.top.bottom.equalTo(view);
        }];
        title.font = [UIFont systemFontOfSize:13];
        title.textColor = MAIN_FONT_COLOR();
        if (section == 1 ) {
            title.text = @"车况";
        }
        return view;
    }else{
        CarConfigResult *info = self.listArray[section - 3];
        
        CarConfigHeaferView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"header"];
        view.label.text = info.confName;
        view.tag = section;
        if (info.selectedState == YES) {
            view.rightImage.image = [UIImage imageNamed:@"up"];
            
        }else{
            view.rightImage.image = [UIImage imageNamed:@"down"];
        }
        
        
        if (view.gestureRecognizers == nil) {
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headerViewClickedAction:)];
            [view addGestureRecognizer:tap];
        }
        
        return view;
    }
   
}

- (void) headerViewClickedAction:(UITapGestureRecognizer *)sender
{
    
    CarConfigResult *info = self.listArray[sender.view.tag - 3];
    
    
    if (info.selectedState == YES) {
        info.selectedState = NO;
        
    }else{
        info.selectedState = YES;
        
    }
    NSIndexSet *set = [NSIndexSet indexSetWithIndex:sender.view.tag];
    [self.tableview reloadSections:set withRowAnimation:UITableViewRowAnimationFade];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 1) {
        return 25;
    }else if (section == 0 || section == 2){

        return 0.00001;
    }
    return 41;
}
/** 点击图片回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    [HUPhotoBrowser showFromImageView:nil withURLStrings:self.imageUrls placeholderImage:[UIImage imageNamed:@"banner"] atIndex:index dismiss:nil];
    NSLog(@"---点击了第%ld张图片", (long)index);
    
}
/** 图片滚动回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index{
    
    NSLog(@"---滚到第%ld张图片", (long)index);
    self.bannerL.text = [NSString stringWithFormat:@"%zd/%zd",index + 1,self.imageUrls.count];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//信息
-(void)loadCarBaseInfo{
    
    [SVProgressHUD show];
    [YQNetworking postWithUrl:[NSString stringWithFormat:@"%@%@",Api,carDetailApi] refreshRequest:YES cache:NO params:@{@"carId":self.carID,@"imageViewId":@(3)} progressBlock:^(int64_t bytesRead, int64_t totalBytes) {
        
    } successBlock:^(id response) {
        _infomodel = [CarBaseInfoModel mj_objectWithKeyValues:response];
        
        if (_infomodel.code == 1) {
            [self.imageUrls removeAllObjects];
            [self.imageDealUrlS removeAllObjects];
            for (NSDictionary *dic in _infomodel.result.carImages) {
                CarCarimages *imagemodel =  [CarCarimages mj_objectWithKeyValues:dic];
                    [self.imageUrls addObject:[NSString stringWithFormat:@"%@%@",ImageApi,imagemodel.imageUrl]];
                    [self.imageDealUrlS addObject:[NSString stringWithFormat:@"%@%@",ImageApi,imagemodel.imageUrl]];
            }
            self.bannerView.imageURLStringsGroup = self.imageDealUrlS;
            self.bannerL.text = [NSString stringWithFormat:@"1/%zd",_imageUrls.count];
            [self.tableview reloadData];
        }
        [self carInfo];
        [SVProgressHUD dismiss];
    } failBlock:^(NSError *error) {
        [ShowMessage showHintMessage:@"请求失败!" duration:2.0 withRemindId:remindFail];
        [SVProgressHUD dismiss];
        
    }];
    
}
//配置

-(void)loadCarConfigInfo{
    
    [SVProgressHUD show];
    [YQNetworking postWithUrl:[NSString stringWithFormat:@"%@%@",Api,carConfApi] refreshRequest:YES cache:NO params:@{@"carId":self.carID,@"modelId":@(self.infomodel.result.model.modelId)} progressBlock:^(int64_t bytesRead, int64_t totalBytes) {
        
    } successBlock:^(id response) {
        CarConfigInfoModel *configInfo = [CarConfigInfoModel mj_objectWithKeyValues:response];
        
        for (NSDictionary *dic in configInfo.result) {
            CarConfigResult *child = [CarConfigResult mj_objectWithKeyValues:dic];
            [self.listArray addObject:child];
            
        }
        
        [self.tableview reloadData];
        [SVProgressHUD dismiss];
        
    } failBlock:^(NSError *error) {
        [ShowMessage showHintMessage:@"请求失败!" duration:2.0 withRemindId:remindFail];

        [SVProgressHUD dismiss];
        
    }];
}

@end
